/*
 * Copyright (C) 2020 Graylog, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the Server Side Public License, version 1,
 * as published by MongoDB, Inc.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * Server Side Public License for more details.
 *
 * You should have received a copy of the Server Side Public License
 * along with this program. If not, see
 * <http://www.mongodb.com/licensing/server-side-public-license>.
 */
import React from 'react';

import { Col, Row, ButtonToolbar } from 'components/bootstrap';
import HideOnCloud from 'util/conditional/HideOnCloud';
import DocsHelper from 'util/DocsHelper';
import { DocumentTitle, PageHeader, IfPermitted } from 'components/common';
import { IndexSetsComponent, IndicesPageNavigation } from 'components/indices';
import { IndexerClusterHealth } from 'components/indexers';
import AllIndicesMaintenanceDropdown from 'components/indices/AllIndicesMaintenanceDropdown';
import CreateButton from 'components/common/CreateButton';

const IndicesPage = () => (
  <DocumentTitle title="Indices and Index Sets">
    <IndicesPageNavigation />
    <PageHeader
      title="Indices & Index Sets"
      actions={
        <ButtonToolbar>
          <CreateButton entityKey="Index Set" />
          <IfPermitted permissions="indexranges:rebuild">
            <AllIndicesMaintenanceDropdown />
          </IfPermitted>
        </ButtonToolbar>
      }
      documentationLink={{
        title: 'Index model documentation',
        path: DocsHelper.PAGES.INDEX_MODEL,
      }}>
      <span>
        A stream writes messages to an index set, which is a configuration for retention, sharding, and replication of
        the stored data. By configuring index sets, you could, for example, have different retention times for certain
        streams.
      </span>
    </PageHeader>

    <HideOnCloud>
      <IndexerClusterHealth minimal />
    </HideOnCloud>

    <Row className="content">
      <Col md={12}>
        <IndexSetsComponent />
      </Col>
    </Row>
  </DocumentTitle>
);

export default IndicesPage;
